from collections import deque

x, y, z = map(int, input().split())
start = (x, y, z)

q = deque([(0, start)])
visited = {start}

while q:
    step, (a, b, c) = q.popleft()
    if a == b == c:
        print(step)
        break
    # 操作 1: 任意两只鸡 +1
    for i, j in [(0,1), (0,2), (1,2)]:
        nxt = [a, b, c]
        nxt[i] += 1
        nxt[j] += 1
        nxt = tuple(nxt)
        if nxt not in visited:
            visited.add(nxt)
            q.append((step+1, nxt))
    # 操作 2: 任意一只鸡 +2
    for i in range(3):
        nxt = [a, b, c]
        nxt[i] += 2
        nxt = tuple(nxt)
        if nxt not in visited:
            visited.add(nxt)
            q.append((step+1, nxt))
